﻿using Digitalmes.Domain.Enums;
using Digitalmes.Domain.Mes;
using Digitalmes.Sugar;

namespace Digitalmes.Scada.Services.Impl;

internal sealed class EquipmentModeService : IEquipmentModeService, ITransientDependency
{
    private readonly SugarRepository<EquipModeRecord> _equipModeRepo;

    public EquipmentModeService(SugarRepository<EquipModeRecord> equipModeRepo)
    {
        _equipModeRepo = equipModeRepo;
    }

    public async Task ChangeModeAsync(string lineCode, string equipCode, EquipRunningMode runningMode)
    {
        await _equipModeRepo.InsertAsync(new EquipModeRecord
        {
            LineCode = lineCode,
            LineName = lineCode,
            EquipCode = equipCode,
            EquipName = equipCode,
            RunningMode = runningMode,
            RecordTime = DateTime.Now,
        });
    }
}
